//
//  HWRecyclingRecordsTableViewCell.m
//  HWanGame
//
//  Created by 陈道斌 on 2021/7/21.
//  Copyright © 2021 Chendaobin. All rights reserved.
//

#import "HWRecyclingRecordsTableViewCell.h"
#import "HWWatchView.h"
#import "HWUndoViewController.h"
@implementation HWRecyclingRecordsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.huiseView.layer.cornerRadius =2;
    self.huiseView.layer.masksToBounds = YES;
    self.huishoujianLabel.layer.cornerRadius =2;
    self.huishoujianLabel.layer.masksToBounds = YES;
    self.huishoujianLabel.backgroundColor = RGB(69, 70, 79);
    
    [self.zhuantaiBut addTarget:self action:@selector(zhuantaiButTap) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}



-(void)setModel:(HWhuishouModel *)model {
    
    _model = model;
    
    
    [self.icoiamgeView sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:nil];
    self.biaotilabel.text = model.gname;
//    self.xiaohaoLabel.text = [NSString stringWithFormat:@"小号昵称：%@",model.user_name];
//    self.chongzhijingLabel.text = [NSString stringWithFormat:@"小号昵称：%@",model.pay];
//    self.huishouLabel.text = [NSString stringWithFormat:@"回收价：%@",model.paymoney];
    NSString *xiaohao =   [NSString stringWithFormat:@"小号昵称：%@",model.user_name];
    
   self.xihaonicheng.attributedText =   [WMUtil attributedStringWithText:xiaohao withRangText:model.user_name withColor:RGB(51, 51, 51) withFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
    
    NSString * shifu   =  [NSString stringWithFormat:@"实际充值金额：%@",model.pay];
    
    self.shijichongzhiLabel.attributedText =   [WMUtil attributedStringWithText:shifu withRangText:model.pay withColor:RGB(51, 51, 51) withFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
    
    NSString *huishou   =  [NSString stringWithFormat:@"回收价：%@",model.paymoney];
    self.huishoujianLabel.attributedText =   [WMUtil attributedStringWithText:huishou withRangText:model.paymoney withColor:RGB(255 , 255, 255) withFont:[UIFont systemFontOfSize:15]];
    
    
    
    NSString *shijian =  [NSString stringWithFormat:@"回收时间：%@",model.time];
 
    self.shijianLabel.attributedText =   [WMUtil attributedStringWithText:shijian withRangText:model.time withColor:RGB(51, 51, 51) withFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
    
   //  0 审核中，1回收成功，2拒绝回收，3已撤销
    if ([model.status intValue] == 0) {
        
        self.shijianLabel.hidden  = YES;
        self.zhuantaiBut.hidden = NO;
        
        self.tupianIcolabel.image  = [UIImage imageNamed:@"shenghezhongico1"];
        self.tupianIcolabel.hidden = NO;
        self.juliright.constant = 0;
        
        
        
    } else if ([model.status intValue] == 1) {
        
        self.shijianLabel.hidden  = NO;
        self.zhuantaiBut.hidden = YES;
        
        self.tupianIcolabel.image  = [UIImage imageNamed:@"shenghezhongico2"];
        self.tupianIcolabel.hidden = NO;
        self.juliright.constant = -30;
        
        
        
        
    }else if ([model.status intValue] == 2) {
        self.shijianLabel.hidden  = NO;
        self.zhuantaiBut.hidden = YES;
        
        self.tupianIcolabel.image  = [UIImage imageNamed:@"shenghezhongico3"];
        self.tupianIcolabel.hidden = NO;
        
        if ([model.note isEqualToString:@""]) {
            self.juliright.constant = -30;
            self.zhuantaiBut.hidden = YES;
        } else {
            
            self.juliright.constant = 0;
            self.zhuantaiBut.hidden = NO;
            
        }
     
        [self.zhuantaiBut setTitle:@"查看" forState:UIControlStateNormal];
        
        
    }else if ([model.status intValue] == 3) {
        
        self.shijianLabel.hidden  = NO;
        self.zhuantaiBut.hidden = NO;
        self.tupianIcolabel.image  = [UIImage imageNamed:@"yichixiao4"];
        self.tupianIcolabel.hidden = NO;
        [self.zhuantaiBut setTitle:@"查看" forState:UIControlStateNormal];
        self.juliright.constant = 0;
        
        
        
      
        
    }
    
    
    
 
    
}

// 点击
- (void)zhuantaiButTap {
     
     
    //  0 审核中，1回收成功，2拒绝回收，3已撤销
     if ([self.model.status intValue] == 0) {
         
           NSLog(@"0审核中");
         
         
         HWUndoViewController *undoView = [[HWUndoViewController alloc]init];
         undoView.idStr =self.model.id;
         
         [[HWViewUtils getCurrentVC].navigationController pushViewController:undoView animated:YES];
         
     
      
         
         
     } else if ([self.model.status intValue] == 1) {
         
         NSLog(@"1回收成功");
         
         
     } else if ([self.model.status intValue] == 2) {
         
         NSLog(@"2拒绝回收");
         
         
         HWWatchView *watchview = [[HWWatchView alloc]init];
         watchview.frame = CGRectMake(0, 0, kScreenW, kScreenH);
         watchview.leirongStr = self.model.note;
         [watchview shuxingview];
         
         [kKeyWindow addSubview:watchview];
         
         
         
         
     } else if ([self.model.status intValue] == 3) {
         
         NSLog(@"3已撤销");
         
         
         NSLog(@"3已撤销 %@",self.model.note);
         
         HWWatchView *watchview = [[HWWatchView alloc]init];
         watchview.frame = CGRectMake(0, 0, kScreenW, kScreenH);
         watchview.leirongStr = self.model.note;
         [watchview shuxingview];
         
         [kKeyWindow addSubview:watchview];
         
         
         
         
     }
    
    
    
    
}





@end
